package com.lfy.modules.common.domain;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

public interface BaseEnum {
    public String getMsg();
    public Integer getCode();
    @AllArgsConstructor
    @Getter
    enum authEnum implements BaseEnum{
        LOGIN_SUCCESS("登录成功",200),
        REGISTER_SUCCESS("注册成功，请前往邮箱激活",200),
        ACTIVATION_SUCCESS("激活成功",200),

        ACTIVATION_ERROR("激活失败",601),
        LOGIN_ERROR("用户名或密码错误",602),
        REGISTER_ERROR("邮箱已注册过",603),

        NO_ACTIVATION("请前往邮箱进行激活",604),
        NO_TIME_LOGIN("请重新登录",401),
        NO_LOGIN("请先登录",403),
        NO_AUTH("你没有权限访问此资源",444),

        USER_NOT_EXIST("用户不存在",605),
        DELETE_ADMIN_ERROR("不能删除超级管理员",606),
        DELETE_LEV_ERROR("不能删除级别比你高的用户",609),
        DELETE_SELF_ERROR("不能删除自己",607),
        DELETE_ERROR("删除失败",608),

        ;


        final String msg;
        final Integer code;
    }
    @Getter
    @AllArgsConstructor
    enum commonEnum implements BaseEnum{
        SUCCESS(200, "成功"),
        SYSTEM_ERROR(-1, "系统出小差了，请稍后再试哦~~"),
        PARAM_VALID(-2, "参数校验失败{0}"),
        FREQUENCY_LIMIT(-3, "请求太频繁了，请稍后再试哦~~"),
        LOCK_LIMIT(-4, "请求太频繁了，请稍后再试哦~~"),
        POST_OR_GET(-5,"get和post弄混了"),
        DOUBLE_SET_UP(-6,"请勿重复操作"),

        ERROR_PARAMS(-211,"参数异常"),
        ERROR_PAGE_SIZE(-212,"页大小异常");
        ;
        private final Integer code;
        private final String msg;
    }
    @Getter
    @AllArgsConstructor
    enum BlackEnum implements BaseEnum{
        BLACK_LIMIT(0,"限流自动封禁"),
        BLACK_MANUAL(1,"管理员封禁"),
        BLACK_HANDLER(-999,"你已被列如黑名单，请联系管理员"),
        FREEZE(-998,"账号已冻结"),
        ;
        private final Integer code;
        private final String msg;
        private static Map<Integer,String> map;
        static {
            map = Arrays.stream(BlackEnum.values()).collect(Collectors.toMap(BlackEnum::getCode, BlackEnum::getMsg));
        }
        public static String getMsg(Integer code){
            return map.get(code);
        }
    }
    @Getter
    @AllArgsConstructor
    enum ChatEnum implements BaseEnum{
        NO_FOUND_AI(1001,"未开通该AI模型"),

        ;
        private final Integer code;
        private final String msg;
    }
}
